﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using MyMES.IServices;
using MyMES.Dto;
using VOL.Core.Utilities.Response;
using VOL.Entity.DomainModels.Core;
using VOL.Entity.DomainModels;
using System.Threading.Tasks;

namespace VOL.WebApi.Controllers.WarehouseManagement
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SNTablesController : ControllerBase
    {
        private readonly ISNTableService _sNTableService;
        private readonly ILogger<SNTablesController> _logger;

        public SNTablesController(ISNTableService sNTableService, ILogger<SNTablesController> logger)
        {
            _sNTableService = sNTableService;
            _logger = logger;
        }

        /// <summary>
        /// 获取SN码列表
        /// </summary>
        /// <param name="dto">查询条件</param>
        /// <returns>分页后的SN码列表</returns>
        [HttpPost]
        public Task<PageGridData<SNTableDTO>> GetSNTable([FromBody]GetSNTableDTO dto)
        {
            return _sNTableService.GetSNTable(dto);
        }

        /// <summary>
        /// 添加SN码
        /// </summary>
        /// <param name="sNTable">SN码实体</param>
        /// <returns>操作结果</returns>
        [HttpPost]
        public async Task<WebResponseContent> AddSNTable([FromBody] SNTable sNTable)
        {
            return await _sNTableService.AddSNTable(sNTable);
        }

        /// <summary>
        /// 删除SN码
        /// </summary>
        /// <param name="id">SN码ID</param>
        /// <returns>操作结果</returns>
        [HttpPost]
        public async Task<WebResponseContent> RemSNTable(string id)
        {
            return await _sNTableService.RemSNTable(id);
        }
    }
}
